package com.jinhongone.pattern.structure.facade;

/*
* Facade：子系统的门面
* */
public class SmartAppliancesFacade {

    private TV tv;
    private Light light;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        this.tv = new TV();
        this.light = new Light();
        this.airCondition = new AirCondition();
    }

    public void say(String msg){
        if(msg.contains("打开")){
            on();
        } else if (msg.contains("关闭")) {
            off();
        }

    }

    private void on(){
        tv.on();
        light.on();
        airCondition.on();
    }

    private void off(){
        tv.off();
        light.off();
        airCondition.off();
    }
}
